<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('分润返现列表')" />
</head>
<style>
    .process{
        margin-top: 45px;
        margin-left: 15px;
    }
</style>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li class="select-time">
                                <label style="width: 80px;">选择日期：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginAddDate"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endAddDate"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="query()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
                    <div class="process"><h4 style="color:blue;">交易总额：<span id="money" style="color: red">0.00</span></h4></div>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "agentInfo/profitSbOrder";
        //刷新页面重新获取统计金额信息
        moneySum();
        $(function() {
            var options = {
                url: prefix + "/cashbackList",

                modalName: "分润返现列表",
                columns: [
                {
                    field: 'AMOUNT',
                    title: '金额',
                    formatter: function (value, row, index) {
                        return $.table.rmbFormatter(value);
                    }
                },
                {
                    field: 'PROFIT_TYPE',
                    title: '类型', //3一段达标返现 4二段达标 5三段达标 6提现奖励
                    formatter:function(value,row,index){
                        if (value == '0'){
                            return '<span style="color: #008000">代理商直推分润</span>';
                        } else if (value == '1'){
                            return '<span style="color: #008000">团队分润</span>';
                        } else if (value == '2'){
                            return '<span style="color: #006dcc">引流奖励</span>';
                        } else if (value == '3'){
                            return '<span style="color: #006dcc">一段达标返现</span>';
                        } else if (value == '4'){
                            return '<span style="color: #006dcc">二段达标返现</span>';
                        } else if (value == '5'){
                            return '<span style="color: #006dcc">三段达标返现</span>';
                        } else if (value == '6'){
                            return '<span style="color: #006dcc">提现奖励</span>';
                        } else if (value == '7'){
                            return '<span style="color: #006dcc">交易增量分润</span>';
                        } else if (value == '8'){
                            return '<span style="color: #006dcc">累计采购分润</span>';
                        } else if (value == '9') {
                            return '<span style="color: #006dcc">分润提现</span>';
                        } else if (value == '10') {
                            return '<span style="color: #006dcc">返现提现</span>';
                        } else if (value == '11'){
                            return '<span style="color: #006dcc">自采购奖励(4元)</span>';
                        } else if (value == '12'){
                            return '<span style="color: #006dcc">团员采购奖励(8元)</span>';
                        } else if (value == '13'){
                            return '<span style="color: #006dcc">云闪付奖励</span>';
                        } else if (value == '14'){
                            return '<span style="color: #006dcc">引流人员奖励政策</span>';
                        } else if (value == '15'){
                            return '<span style="color: #006dcc">引流人员入团补差</span>';
                        } else if (value == '16') {
                            return '<span style="color: #006dcc">累计采购奖励政策</span>';
                        } else if (value == '17') {
                            return '<span style="color: #006dcc">团交易同比增量奖励</span>';
                        } else if (value == '18') {
                            return '<span style="color: #006dcc">交易量新增一千万返现</span>';
                        }else if (value == '19') {
                            return '<span style="color: #006dcc">雏鹰计划奖励</span>';
                        }else if (value == '20') {
                            return '<span style="color: #006dcc">210激团奖（团长引流奖励 A）</span>';
                        }else if (value == '21') {
                            return '<span style="color: #006dcc">传统引流奖励</span>';
                        }else if (value == '22') {
                            return '<span style="color: #006dcc">分润税奖励</span>';
                        }else if (value == '24') {
                            return '<span style="color: #006dcc">底薪计划</span>';
                        }else if (value == '25') {
                            return '<span style="color: #006dcc">流量卡返现</span>';
                        }else if (value == '26') {
                            return '<span style="color: #006dcc">机具尾款返现</span>';
                        }else if (value == '27') {
                            return '<span style="color: #006dcc">采购人奖励</span>';
                        }else if (value == '28') {
                            return '<span style="color: #006dcc">GB传统增量奖</span>';
                        }else if (value == '29') {
                            return '<span style="color: #006dcc">GB传统增量奖(团长)</span>';
                        }else if (value == '30') {
                            return '<span style="color: #006dcc">GB传统引流奖励</span>';
                        }else if (value == '31') {
                            return '<span style="color: #006dcc">GB传统引流奖励(团长)</span>';
                        }else if (value == '32') {
                            return '<span style="color: #006dcc">采购返现奖励2</span>';
                        }else {
                            return '<span style="color: #ff0000">未知</span>';
                        }
                    }
                },

                ]
            };
            $.table.init(options);
        });
        //获取总额统计
        function moneySum () {
            var beginAddDate = $("#startTime").val()
            var endAddDate = $("#endTime").val()
            var data = {"beginAddDate":beginAddDate,"endAddDate":endAddDate};
            $.ajax({
                type: "post",
                url: prefix + "/cashbackListSum",
                dataType: "json",
                data: data,
                async:false,
                success: function (result) {
                    if (result.code == '0'){
                        //没有符合条件的结果
                        if ($.common.isNotEmpty(result.rows)){
                            $("#money").html($.table.rmbFormatter(result.rows[0].AMOUNT))
                        } else {
                            $("#money").html("0.00")
                        }
                    } else {
                        $("#money").html("0.00")
                    }
                },
                error:function (result) {
                    $("#money").html("0.00")
                }
            })
            return;
        };

        /**
         * 自定义搜索
         */
        function query() {
            moneySum();
            $.table.search()
        }


    </script>
</body>
</html>